package com.gufe.service.admin.impl.mmp;

import com.gufe.dto.SwiperDTO;
import com.gufe.entity.Swiper;
import com.gufe.mapper.admin.mmp.SwiperMapper;
import com.gufe.service.admin.mmp.SwiperService;
import com.gufe.vo.SwiperVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class SwiperServiceImpl implements SwiperService {

    @Autowired
    SwiperMapper swiperMapper;

    /*获取所有轮播图图片及描述*/
    @Override
    public List<SwiperVO> getAllIndexImg() {
        return swiperMapper.getAllIndexImg();
    }

    /*根据ID查询轮播图信息*/
    @Override
    public SwiperVO getIndexImgById(int id) {
        Swiper swiper = swiperMapper.getIndexSwiperById(id);
        SwiperVO swiperVO = new SwiperVO();
        BeanUtils.copyProperties(swiper, swiperVO);
        return swiperVO;
    }

    /*修改轮播图图片*/
    @Override
    public void updateIndexImg(SwiperDTO swiperDTO) {
        Swiper swiper = new Swiper();
        BeanUtils.copyProperties(swiperDTO, swiper);
        swiper.setUpdatedAt(LocalDateTime.now());
        swiperMapper.updateIndexSwiper(swiper);
    }

    @Override
    public List<SwiperVO> getAllPPTSwiper() {
        return swiperMapper.getAllPPTSwiper();
    }

    @Override
    public SwiperVO getPPTSwiperById(Integer id) {
        return swiperMapper.getPPTSwiperById(id);
    }

    @Override
    public void updatePPTSwiper(SwiperDTO swiperDTO) {
        Swiper swiper = new Swiper();
        BeanUtils.copyProperties(swiperDTO,swiper);
        swiperMapper.updatePPTSwiper(swiper);
    }
}
